﻿using System.Reflection;

namespace ApiScannerShell
{
    class SimpleMapping<TModel> : ModelMapping<TModel>
    {
        private readonly PropertyInfo _ModelProperty;

        public SimpleMapping(string propertyName)
        {
            _ModelProperty = typeof (TModel).GetProperty(propertyName);
        }

        public override object LoadValue(TModel model)
        {
            return _ModelProperty.GetValue(model, null);
        }

        public override void SetValue(object value, TModel model)
        {
            _ModelProperty.SetValue(model, value, null);
        }
    }
}